/*--------------------------------------------------------------------------------*/
#ifndef __INTERFACE_OBJECT__
#define __INTERFACE_OBJECT__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "object.h"
#include "util.h"
#include "property_table.h"
#include "timer.h"
/*--------------------------------------------------------------------------------*/
class INTERFACE_OBJECT : public OBJECT
{

	// -- PUBLIC

public:

    DECLARE_REF( INTERFACE_OBJECT );

    // .. CONSTRUCTORS

    INTERFACE_OBJECT() :
    	OBJECT(),
    	ItIsSelected( false ),
    	ItIsVisible( true ),
    	Properties()
    {

    }

    ~INTERFACE_OBJECT()
    {
     
    }

    // .. METHODS

    VOID SetExtent( const MATH_VECTOR_2 & extent )
    {
    	Extent = extent;
    }

    VOID SetPosition( const MATH_VECTOR_2 & position )
    {
    	Position = position;
    }

    VOID Show()
    {
    	ItIsVisible = true;
    }

    VOID Hide()
    {
    	ItIsVisible = false;
    }

    VOID Select()
    {
    	ItIsSelected = true;    	
    	OnSelectionChanged();
    }

    VOID Unselect()
    {
    	ItIsSelected = false;    	
    	OnSelectionChanged();
    }

    BOOL IsSelected() const
    {
    	return ItIsSelected;
    }

    BOOL IsVisible() const
    {
    	return ItIsVisible;
    }

    virtual VOID Initialize( const PROPERTY_TABLE & properties )
    {
    	Properties = properties;

		SetPosition( properties.GetVector2( "position" ) );
		SetExtent( properties.GetVector2( "extent" ) );
    }

    virtual VOID Update( const TIMER & timer ) = 0;
    virtual VOID Render() = 0;
    
    virtual VOID OnSelectionChanged() {}

    TEXT GenerateScript()
    {
    	//:TODO:
		return "";
    }
    
    // -- PROTECTED

protected :

    // .. ATTRIBUTES

    MATH_VECTOR_2
		Position,
		Extent;
    BOOL
    	ItIsSelected,
    	ItIsVisible;
    PROPERTY_TABLE
    	Properties;
};
/*--------------------------------------------------------------------------------*/
#endif
